# _*_ coding: utf-8 _*_
# @Time     : 2022/7/23 14:45
# @Author   : dake
# @Email    : dake@2545923.com
# @File     : mine_page.py
# @Software : PyCharm
from selenium.webdriver.common.by import By
import unittest
from pages.base_page import BasePage


class MinePage(BasePage):
    """我的  页面类"""
    user = "煮米cLiFD5"
    attention_locator = (By.ID, "com.gfeng.daydaycook:id/ll_attention")  # 进入关注页面按钮
    no_attention_locator = (By.ID, "com.gfeng.daydaycook:id/iv_focus_status")  # 点击关注按钮
    production_locator = (By.ID, "com.gfeng.daydaycook:id/title")  # 作品
    management_locator = (By.ID, 'com.gfeng.daydaycook:id/tv_nickName')  # 设置用户信息时使用
    attention_num_locator = (By.ID, "com.gfeng.daydaycook:id/tv_attention_count")  # 关注人数
    return_locator = (By.ID, "com.gfeng.daydaycook:id/backButton")  # 返回上一页面
    # return1_locator = (By.ID, "com.gfeng.daydaycook:id/iv_back")  # 收藏返回上一页面

    def ele_attention(self):
        """进入关注用户页面"""
        self.driver.find_element(*self.attention_locator).click()

    def ele_no_attention(self):
        """点击关注取消关注"""
        self.driver.find_elements(*self.no_attention_locator)[1].click()

    def ele_production(self):
        """点击作品"""
        self.driver.find_elements(*self.production_locator)[0].click()

    def ele_collect(self):
        """点击收藏"""
        self.driver.find_element_by_android_uiautomator('new UiSelector().text("收藏")').click()

    def ele_collect_menu(self, x=990, y=1810):
        """点击菜谱里面的收藏"""
        self.driver.tap([(x, y)])

    def ele_set(self):
        """点击用户名进行修改"""
        self.driver.find_element(*self.management_locator).click()

    def ele_return(self):
        """返回上一页面"""
        self.driver.find_element(*self.return_locator).click()

    def ele_return1(self):
        """收藏返回上一页面"""
        self.driver.press_keycode("4")

    def get_set(self):
        """获取元素的值"""
        return self.driver.find_element(*self.management_locator).text

    def get_attention_num(self):
        """获取关注人数"""
        return self.driver.find_element(*self.attention_num_locator).text

    def get_production(self):
        """获取收藏第一个作品的标题"""
        return self.driver.find_elements(*self.production_locator)[0].text




if __name__ == "__main__":
    unittest.main()
